function gettreecode(){
    var treename=localStorage.getItem("treename");
    console.log("----------------------")
    console.log(treename);
    console.log("----------------------")
    $("#kcfl").val(treename);

}
var sid=localStorage.getItem("selectmicroid");
$("#sid").val(sid);
console.log(sid);
$.ajax({
    type: "get",
    url: "/advanced/selectpermissionsbyid",
    data:{id:sid},
    success:function(res){
        console.log(res.data);
        console.log(res.data.name);
        $("#bmmc").val(res.data.departmentname);
        $("#cjr").val(res.data.adminname);
        $("#cjtime").val(res.data.createtime);
        $("#bmgs").val(res.data.departmentdescription);
    }
})
layui.use(['upload', 'element', 'layer','form'], function () {
    var upload = layui.upload,//得到 upload 对象
        form=layui.form;
    form.on('submit(formDemo)', function(data){
        console.log(data.field);
        $.ajax({
            type: "post",
            url: "/advanced/updatapermissionstable",
            data:data.field,
            success:function(res){
                if(res.state==200){
                    parent.refresh1();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            }
        })
    });
    //创建一个上传组件
    upload.render({
        elem: '#uploadVideo'
        , url: '/intermediate/upload'
        , accept: 'video'//视频
        , done: function (res) {//上传后的回调
            if (res.code == 0) {
                $("#videoplay").attr("src", res.path);
                $("#video").val(res.path);
                $("#time").val(res.time);
                layer.msg('上传成功');
            } else {
                layer.msg('上传失败');
            }
        }
        , error: function () {
            //请求异常回调
            layer.msg('上传失败');
        }
    })
    var uploadInst = upload.render({
        elem: '#test1'
        , url: '/tp/upload' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
        , before: function (obj) {
            //预读本地文件示例，不支持ie8
            obj.preview(function (index, file, result) {
                $('#demo1').attr('src', result); //图片链接（base64）
            });
        }
        , done: function (res) {
            console.log(res.src);
            //如果上传失败
            if (res.code > 0) {
                return layer.msg('上传失败');
            }
            $("#piano").val(res.src);
            //上传成功的一些操作
            //……
            $('#demoText').html(''); //置空上传失败的状态
        }
        , error: function () {
            //演示失败状态，并实现重传
            var demoText = $('#demoText');
            demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function () {
                uploadInst.upload();
            });
        }
    });
})
$("#selectadd").click(function () {
    layer.open({
        type: 2,
        title: '添加',
        content: "coursetree.html",
        area: ['80%', '80%'],
        end:function (){
            gettreecode();
        }
    })
})
